﻿/*
Copyright (c) 2009 Vratislav Cermak (vratacermak@gmail.com)
 
This file is part of TeachMe Project. See http://code.google.com/p/teach-me for more information.
 
TeachMe is an open source project. Using of TeachMe is free of charge.
It is distributed under GNU General Public License version 3 (GPLv3).
GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
 
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

using System;
using System.Collections.Generic;
using TeachMe.Application.Properties;

namespace TeachMe.Application.Data
{
    public class Entries
    {
        private readonly Dictionary<int, Entry> _items = new Dictionary<int, Entry>();
        private readonly Guid _id;
        private string _name;
        private string _description;
        private string _from;
        private string _to;

        public Entries(Guid id, string name, string description, string from, string to)
        {
            _id = id;
            _name = name;
            _description = description;
            _from = from;
            _to = to;
        }

        public bool OneWay
        {
            get
            {
                return String.Compare(_from.Trim(), _to.Trim(), true) == 0;
            }
        }

        public static int Version
        {
            get { return 1; }
        }

        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
            }
        }

        public string Description
        {
            get
            {
                return _description;
            }
            set
            {
                _description = value;
            }
        }

        public string From
        {
            get
            {
                return _from;
            }
            set
            {
                _from = value;
            }
        }

        public string To
        {
            get
            {
                return _to;
            }
            set
            {
                _to = value;
            }
        }

        public Guid Id
        {
            get
            {
                return _id;
            }
        }

        public int Count
        {
            get
            {
                return Items.Count;
            }
        }

        public Dictionary<int, Entry> Items
        {
            get { return _items; }
        }

        public override string ToString()
        {
            if (!String.IsNullOrEmpty(Description))
            {
                return String.Format(Resources.DictionaryNameWithDescription, Name, Description);
            }
            return String.Format(Resources.DictionaryName, Name);
        }
    }
}
